import {REFRESH_PAGE_TYPE} from "@/views/business/constantData";
import InfoPageContainer from "@/components/InfoPageContainer/index.vue";
import LayoutContainer from "@/components/layoutContainer/index.vue";
import {isArr} from "@/utils/arrayUtil";

const infoPageMixins = {
  components: {
    InfoPageContainer,
    LayoutContainer
  },
  props: {
    currentItem: {
      type: Object
    }
  },
  data() {
    return {
      dataItem: {

      }
    }
  },
  watch: {
    currentItem() {
      this.setCurrentItem(this.currentItem)
    }
  },
  methods: {
    setCurrentItem(currentItem) {
      this.dataItem = _.cloneDeep(this.currentItem)
    },
    cancel() {
      this.goListPage(REFRESH_PAGE_TYPE.NO_REFRESH)
    },
    saveFinish() {
      this.goListPage(REFRESH_PAGE_TYPE.REFRESH)
    },
    goListPage(type) {
      this.$emit('goListPage', type)
    }
  }
}

export {infoPageMixins}
